// pages/party/party.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [
      '/images/banner/2.jpg',
      '/images/banner/3.jpg',
      '/images/banner/4.jpg',
      '/images/banner/5.jpg'
    ],
    activities: [{
      id: 3,
      img: '/images/activities/3.png',
      title: '与稻草人相约，魔都线下端午'
    }, {
      id: 2,
      img: '/images/activities/2.png',
      title: '与稻草人相约，魔都线下端午'
    }, {
      id: 1,
      img: '/images/activities/1.png',
      title: '与稻草人相约，魔都线下端午'
    }, {
      id: 4,
      img: '/images/activities/4.png',
      title: '与稻草人相约，魔都线下端午'
    }],
    users: [{
      id: 1,
      avatar: "/images/avatar/1.jpg",
      name: "王路飞",
      gender: "男生",
      mobile: "13289006721",
      summary: "看电影",
      photos: ["http://www.weifuw.com/img/1.jpg", "http://www.weifuw.com/img/2.jpg"],
      address: "广东省深圳市南山区粤海街道",
      ctime: "2018-08-31 09:25:00",
      views: 129,
      praises: 32
    }, {
      id: 1,
      avatar: "/images/avatar/1.jpg",
      name: "王路飞",
      gender: "男生",
      mobile: "13289006721",
      summary: "打羽毛球",
      photos: ["http://www.weifuw.com/img/3.jpg", "http://www.weifuw.com/img/4.jpg"],
      address: "广东省深圳市南山区粤海街道",
      ctime: "2018-08-31 09:25:00",
      views: 129,
      praises: 32
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    wx.request({
      url: app.globalData.host,
      data: {
        action: "activity.getList"
      },
      header: {
        'content-type': 'application/json',
        'sid': 'application/json'
      },
      success: function(res) {
        console.log(res);


      }
    });
  },

  previewImage: function(e) {
    console.log(e.currentTarget);
    console.log(this.data.users[e.currentTarget.dataset.index].photos);
    wx.previewImage({
      current: e.currentTarget.dataset.src, // 当前显示图片的http链接
      urls: this.data.users[e.currentTarget.dataset.index].photos // 需要预览的图片http链接列表
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },
  showDetail: function(e) {
    console.log(e.currentTarget.dataset.id);
    wx.navigateTo({
      url: '../activity-detail/activity-detail?id=' + e.currentTarget.dataset.id,
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})